<%-- 
    Document   : LoginTest
    Created on : 22.04.2011, 22:59:23
    Author     : ain
--%>

<%@page import="unc.pds.service.ServiceBeanRemote"%>
<%@page import="unc.pds.data.Consts"%>
<%@page import="unc.pds.util.ArchImpl"%>
<%@page import="unc.pds.util.Arch"%>
<%@page import="unc.pds.service.RegisterRemoteHome"%>
<%@page import="unc.pds.service.RegisterRemote"%>
<%@page import="unc.pds.model.UserRemote"%>
<%@page import="unc.pds.service.LoginRemoteHome"%>
<%@page import="unc.pds.service.LoginRemote"%>
<%@page import="javax.naming.InitialContext"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Register</title>
    </head>
    <body>
        <form action="RegisterPage.jsp" >
            <input type="text" name="name" value="ain">
            <input type="text" name="pass" value="1234">
            <input type="submit" name="register" value="register">
        </form>
        <%
        if (request.getParameter("name")!=null){
            RegisterRemote RegisterR = ((RegisterRemoteHome)(new InitialContext()).lookup("ejb/Register")).create();
            Arch doc = new ArchImpl("root","null");
            doc.addChild(new ArchImpl(Consts.ATTR__USER_NICKNAME,request.getParameter("name")));
            doc.addChild(new ArchImpl(Consts.ATTR__USER_PASSWORD,request.getParameter("pass")));
            ServiceBeanRemote sbr = RegisterR.register(doc);
            session.setAttribute("service", sbr);
            if (sbr.getUser()!=null) out.println("SUCCESS. Hello, "+sbr.getUser().getNickname());
        }
        %>
    </body>
</html>
